<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>axios批量发送请求</title>
		<script type="text/javascript" src="./js/axios.min.js"></script>
	</head>
	<body>
		<button onclick="demo()">很复杂的一个业务逻辑，要发3个请求</button>

		<script type="text/javascript" >
			/* function demo(){
				const p1 = axios({
					url:'http://localhost:5000/hello',
					params:{delay:2000}
				})
				const p2 = axios({
					url:'http://localhost:5000/hello',
					params:{delay:3000}
				})
				const p3 = axios({
					url:'http://localhost:5000/hello',
					params:{delay:1000}
				})
				
				axios.all([p1,p2,p3]).then(
					value => console.log('成功了',value),
					reason => console.log('失败了',reason)
				)
			} */
			
			async function demo(){
				const p1 = await axios({
					url:'http://localhost:5000/hello',
					params:{delay:1000}
				})
				const p2 = await axios({
					url:'http://localhost:5000/hello',
					params:{delay:3000}
				})
				const p3 = await axios({
					url:'http://localhost:5000/hello',
					params:{delay:2000}
				})
				console.log(p1,p2,p3)
			}
		</script>
	</body>
</html>